﻿<%@ Control Language="C#" ClassName="ProductItemControl" %>
<%@ Register Src="~/UserControls/ProductLinkControl.ascx" TagPrefix="ProductLink" TagName="ProductLinkControl" %>

<script runat="server">
  public string ProductText { get; set; }
  public string ProductCategory { get; set; }

  protected void Page_Load(object sender, EventArgs e)
  {
    if (!Page.IsPostBack)
    {
      Literal_ProductText.Text = ProductText;
      B2C_MALL_HOME ws = new B2C_MALL_HOME();
      ws.Url = ConfigurationManager.AppSettings["B2C_MALL_HOME"].ToString(); 
      string jsonString = ws.B2C_MALL_getBoards(System.Configuration.ConfigurationManager.AppSettings["WebDeviceid"].ToString()
        , HttpContext.Current.User.Identity.Name, ProductCategory);
      JObject restoredObject = JsonConvert.DeserializeObject<JObject>(jsonString);
      string Is_Valid = restoredObject["Is_Valid"].ToString();
      string msg = restoredObject["Msg"].ToString();
      if (Is_Valid == "Y")
      {
        dynamic dynObj = restoredObject["Prd_Ary"];
        foreach (var ja in dynObj)
        {
          ProductLinkControl ProductLink =
           (ProductLinkControl)this.LoadControl("~/UserControls/ProductLinkControl.ascx");
          ProductLink.Prd_Ary = ja;
          //ProductLink.ProductImageUrl = ja.IMAGE_PATH_M;
          //ProductLink.ProductLink = "~/Products/ProductDetail.aspx?B2C_CODE=" + ja.B2C_CODE;
          //ProductLink.ProductInfo = ja.B2C_CODE_NAME;
          //ProductLink.ProductPrice = ja.ACT_PRICE.ToString("n0");
          //ProductLink.LightStatus = ja.light_status;
          image_container.Controls.Add(ProductLink);
        }
      }
      else
      {
        ProductLinkControl ProductLink =
           (ProductLinkControl)this.LoadControl("~/UserControls/ProductLinkControl.ascx");
        image_container.Controls.Add(ProductLink);
      }
    }
  }
</script>

<div class="list-item">
  <h5>
  <asp:Literal ID="Literal_ProductText" runat="server"></asp:Literal></h5>
  <asp:Panel ID="image_container" runat="server" CssClass="image-container"/>
</div>
